/** testlist.d: The unit test for dotmars/base/collection/list.d

  Written in the D programming language 1.0

Authors:	Wei Li <oldrev@gmail.com>
Copyright:	Copyright (C) 2007 by Wei Li.
License:	BSD
*/

module test.base.testlist;

import dotmars.base.collection.list;
import dotmars.test.core;

class ListTestCase : TestCase!(ListTestCase)
{
	this()
	{
		register("testList", &testList);
	}

	void testList() 
	{
		alias List!(int) MyList;

		auto list = new MyList;

		list ~= 1; // this is equal to list.addList(1);
		list ~= 2;
		list ~= 3;
		list ~= 4;
		list ~= 5;
		list ~= 6;
		list.addFirst(7);

		//现在序列为： 7,1,2,3,4,5,6

		MyList.Iterator it = list.begin();
		++it;
		++it;

		//删除2, it 指向3
		it = list.remove(it);

		//现在序列为： 7,2,3,4,5,6

		list.addBefore(it, 2); //在3之前插入2，it 指向 3
	}

}

